package com.shop2cn.iapi.coupon.service;

import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.google.gson.JsonArray;
import com.shop2cn.iapi.coupon.parameter.UserReceiveResultInfo;
import com.shop2cn.iapi.coupon.parameter.batchInfo;
import com.shop2cn.iapi.coupon.parameter.batchInfos;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取可领的买手优惠券批次列表Call
*FreeMaker Template自动生成代码
*/
public class QueryReceivableSellerBatchCall extends YmatouBaseCall{
	private static String opurl ="api/Promotion/QueryReceivableSellerBatch";
	
	public QueryReceivableSellerBatchCall() {
		super(EnvSetup.getSystemUrl("coupon_shop2cn_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("statusCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Message
	 * 
	 * @return
	 */
	public String getMessage() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public String getData() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	public batchDtos getbatchDtosResult()
	{
		batchDtos data = null;
        try {//parseJsonObj  DataUtil.Json.parseJsonArray
           // data = (batchDtos) FormatUtil.GSONToObject(new JSONObject(getData()).getString("batchDtos"), batchDtos.class);
           data = (batchDtos) FormatUtil.GSONToObject(getString("data"), batchDtos.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
	}
	
	
	
	public class batchDtos {
		 List<batchInfo> batchDtos;

		public List<batchInfo> getBatchDtos() {
			return batchDtos;
		}

		public void setBatchDtos(List<batchInfo> batchDtos) {
			this.batchDtos = batchDtos;
		}
		 
	}
	
}